/**  
 * File Name:SpecialStringDerializer.java  
 * Package Name:com.suneee.core.util  
 * Description: (That's the purpose of the file)
 * Date:2015年1月19日上午10:52:54  
 * Copyright (c) 2015, forint.lee@qq.com All Rights Reserved.  
 *  
*/

package com.base.core.type;

import java.io.IOException;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;

/**  
 * ClassName:SpecialStringDerializer <br/>  
 * Description:That's the purpose of the class
 * Date:     2015年1月19日 上午10:52:54 <br/>  
 * @author   Forint  
 * @version  V1.0  
 * @see        
 */
public class SpecialStringDerializer extends JsonDeserializer<String> {
    
    @Override
    public String deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
        JsonToken currentToken = jp.getCurrentToken();
        if (currentToken == JsonToken.VALUE_STRING) {
            return jp.getText().trim();
        }
        return jp.getText();
    }
    
}
